import { request } from './utils'
/**
 * 登录
 * @param {object} userInfo 用户信息
 */
export async function login(userInfo) {
    return await request('login', { userInfo });
}

/**
 * 创建画板
 * @param {object}} userInfo 用户信息
 */
export async function createDrawBoard(userInfo) {
    return await request('createDrawBoard', { userInfo });
}

/**
 * 获取画板信息
 * @param {string} id 画板 id
 */
export async function getDrawBoardById(drawBoardId) {
    return await request('getDrawBoardById', { drawBoardId });
}

/**
 * 修改画板标题
 * @param {string} drawBoardId 画板 id
 * @param {string} title 画板 title
 */
export async function changeTitle(drawBoardId, title) {
    return await request('changeTitle', { drawBoardId, title });
}

/**
 * 新增操作
 * @param {string} drawBoardId 画板 id
 * @param {object} operate 操作
 */
export async function addOperate(drawBoardId, operate) {
    return await request('addOperate', { drawBoardId, operate });
}

/**
 * 撤销操作
 * @param {string} drawBoardId 画板 id
 * @param {number} index 要撤销的操作 index
 */
export async function revokeOperate(drawBoardId, index) {
    return await request('revokeOperate', { drawBoardId, index });
}

/**
 * 重置操作
 * @param {string} drawBoardId 画板 id
 */
export async function resetOperate(drawBoardId) {
    return await request('resetOperate', { drawBoardId });
}

/**
 * 新增成员操作
 * @param {string} drawBoardId 画板 id
 * @param {string} auth 用户权限
 */
export async function addMember(drawBoardId, auth, userInfo) {
    return await request('addMember', { drawBoardId, auth, userInfo });
}

/**
 * 更新图片 id
 * @param {string} drawBoardId 画板 id
 * @param {string} imgId 图片 id
 */
export async function updateImgId(drawBoardId, imgId) {
    return await request('updateImgId', { drawBoardId, imgId });
}

/**
 * 获取用户所有画板数据
 */
export async function getAllDrawBoard() {
    return await request('getAllDrawBoard');
}

/**
 * 获取 imgId
 * @param {string} drawBoardId 画板 id
 */
export async function getImgId(drawBoardId) {
    return await request('getImgId', { drawBoardId });
}

/**
 * 删除画板
 * @param {string} drawBoardId 画板 id
 */
export async function deleteDrawBoard(drawBoardId) {
    return await request('deleteDrawBoard', { drawBoardId });
}

/**
 * 更新用户权限
 * @param {string} drawBoardId 
 * @param {string} openId 
 * @param {string} auth 
 */
export async function changeMember(drawBoardId, openId, auth) {
    return await request('changeMember', { drawBoardId, openId, auth });
}

/**
 * 删除用户
 * @param {string} drawBoardId 
 * @param {string} openId 
 */
export async function deleteMember(drawBoardId, openId) {
    return await request('deleteMember', { drawBoardId, openId });
}